//
// Created by t400 on 2016/11/18.
//

#include "index.h"
#include "xxtea.h"

JNIEXPORT jstring JNICALL Java_com_noble_library_utils_JniUtil_GetEncryptString
        (JNIEnv *env, jclass jcls, jstring jstr){
    std::string strTemp = jstringTostring(env,jstr);
    std::string strResult = GetEncryptString(strTemp);
    return env->NewStringUTF(strResult.c_str());
}

JNIEXPORT jbyteArray JNICALL Java_com_noble_library_utils_JniUtil_GetDecryptString
        (JNIEnv *env, jclass jcls, jstring jstr){
    std::string strTemp = jstringTostring(env,jstr);
    std::string strResult = GetDecryptString(strTemp);
    jbyteArray bytes = env->NewByteArray((jsize) strlen(strResult.c_str()));
    env->SetByteArrayRegion(bytes, 0, (jsize) strlen(strResult.c_str()), (jbyte*)strResult.c_str());
    return bytes;
}
